// 贪心; 时间复杂度O(n); 空间复杂度O(1)

class Solution {
public:
    int balancedStringSplit(string s) {
        int ret = 0, count = 0;
        for (auto c: s) {
            c == 'L' ? ++count : --count;
            if (count == 0) ++ret;
        }
        return ret;
    }
};